package persistencia;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.ForeignKey;

@Entity
@Table(name = "TBL_CLIENTE")
public class Cliente {
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "CLI_ID")
	private int id;

	@Column(name = "CLI_NOME", length = 50)
	private String nome;

	@Column(name = "CLI_RG", length = 15)
	private String rg;

	@Column(name = "CLI_CPF", length = 15)
	private String cpf;

	@Column(name = "CLI_RENDA", precision = 7, scale = 2)
	private double renda;

	@Column(name = "CLI_LIMITE", precision = 5, scale = 2)
	private double limite;

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinColumn(name = "TBL_CLIENTE_CLI_ID")
	@ForeignKey(name = "fk_TBL_ENDERECO_TBL_CLIENTE_idx")
	private List<Endereco> endereco = new ArrayList<Endereco>();

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinColumn(name = "TBL_CLIENTE_CLI_ID")
	@ForeignKey(name = "fk_TBL_END_TBL_CLIENTE_idx")
	private List<Telefone> telefone = new ArrayList<Telefone>();

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getRg() {
		return rg;
	}

	public void setRg(String rg) {
		this.rg = rg;
	}

	public String getCpf() {
		return cpf;
	}

	public void setCpf(String cpf) {
		this.cpf = cpf;
	}

	public double getRenda() {
		return renda;
	}

	public void setRenda(double renda) {
		this.renda = renda;
	}

	public double getLimite() {
		return limite;
	}

	public void setLimite(double limite) {
		this.limite = limite;
	}

	public List<Endereco> getEndereco() {
		return endereco;
	}

	public void setEndereco(List<Endereco> endereco) {
		this.endereco = endereco;
	}

	public List<Telefone> getTelefone() {
		return telefone;
	}

	public void setTelefone(List<Telefone> telefone) {
		this.telefone = telefone;
	}
}
